import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    //赋值[]刷新会丢失数据
    //使用本地保存
    rightList:JSON.parse(localStorage.getItem('rightList')||"[]"),
    username:localStorage.getItem('username')||''
  },
  mutations: {
    setRightList(state,data){
    state.rightList=data
    localStorage.setItem('rightList',JSON.stringify(data))
    },
    setUsername(state,data){
      state.username=data
      localStorage.setItem('username',data)
    }
  },
  actions: {
  },
  modules: {
  }
})
